<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<head>
    <style type="text/css">
            .labelsAndValues-labelCell { background-color: #E0E690; padding-left: 5px; } 
    </style>
    <script type="text/javascript">
       dojo.require("dojo.parser");
       dojo.require("dijit.dijit");
       dojo.require("dijit.form.Form");
       dojo.require("dijit.form.Button");
       dojo.require("dijit.form.TextBox");      
       dojo.require("dojox.layout.TableContainer"); 
       dojo.require("dojox.data.QueryReadStore");      
    </script>
</head>
<div dojoType="dijit.form.Form" id="dataForm" jsId="dataForm" action="buyNow.htm" method="get">
 	<div dojoType="dojox.layout.TableContainer" cols="1" id="tcConfirmPopup" customClass="labelsAndValues">
 		<label>Do you want to continue ?</label>    
 	</div>
 	<button type="submit" dojoType="dijit.form.Button" id="submitButton"  jsId="submitButton" onclick="submitForm();">Yes</button>
 	<button dojoType="dijit.form.Button" id="cancelButton" onclick="dijit.byId('loadDiv').hide();" >No</button>
 	<input type="hidden" id="selectedIds" name="selectedIds"/>
</div>
<script type="text/javascript">
dojo.addOnLoad(function(){
	var dialog = dijit.byId('loadDiv');
	dialog.reset();
	dialog.titleNode.innerHTML = 'Place Order';
});

	function submitForm() {	
        var items = cartGrid.selection.getSelected();
        var selectedItems = new Array();
            if (items.length) {
                dojo.forEach(items, function(selectedItem) {
                    if (selectedItem !== null) {
                        dojo.forEach(cartGrid.store.getAttributes(selectedItem), function(attribute) {                                	
                            // Get the value of the current attribute:
                            if (attribute == "Id") {
                            	var value = cartGrid.store.getValues(selectedItem, attribute);
                            	selectedItems.push(value);                                    
                            	
                            }
                        }); // end forEach
                    } // end if
                }); // end forEach
            } // end if           
            dojo.byId("selectedIds").value=selectedItems;
            var xhrArgs = {
                form: dojo.byId("dataForm"),
                handleAs: "text",
                content: {selectedIds: selectedItems},
            }
            //Call the asynchronous xhrPost
            dojo.byId("response").innerHTML = "Form being sent..."
            var deferred = dojo.xhrPost(xhrArgs);
	}
</script>
